{include file='header.html'}
<style type="text/css">
<!--
body {
	margin-left: 5px;
	margin-top: 1px;
	margin-right: 5px;
	margin-bottom: 1px;
	background-color: #1D3647;
}
-->
</style>
<table style="border:0px;width:100%;border-collapse:collapse; border-spacing:0px;">
   <tr>
      <td valign="top" style="padding:0px;">
      <table class="login_top_bg" 
      	style="border:0px;width:100%;
			background-image: url(./img/login-top-bg-small.png);
			background-repeat: repeat-x; 
			border-collapse:collapse; border-spacing:0px; 
			background-color:#2d475d;">
        <tr style="padding:0px; 
        	background-image:url({$rtvdir}/img/login-top-bg-small-updown.png); 
        	background-repeat:repeat-x;">
          <td width="33%" style="padding:0px;height:27px;width:33%;">
          	<a href="{$url}" 
          		style="color:#ABCAD3;font-weight:bold;font-size:16px;font-family:Tahoma,Geneva,sans-serif;"
          		title="HomePage/首頁">
          		&nbsp;{$lang['agentname']} </a>
          </td>
          <td width="10%" style="padding:0px;max-width:180px;"> <div id="top_notice_div" 
          	style="position:absolute; max-width:180px; top:10px; left:50px; text-align:center;z-index:99;"></div> 
          </td>
          <td id="searchform">
			<form id="insitesearch" 
                  action="{$rtvdir}/extra/insitesearch.php?sid={$sid}&db={$db}&issubmit=1&tit=InSiteSearch&act=init" 
                  method="post">
                    <input id="isskw" name="isskw" placeholder="Searching..." 
                        style="width:80px;background-color:silver;text-align:center;vertical-align:middle;">
            </form>
          </td>
          <td width="52%" style="text-align:right;padding:0px;" class="login-buttom-txt"> {$welcomemsg} </td>
        </tr>
      </table>
      </td>
    </tr>

  <tr>
    <td style="padding:0px; vertical-align:top;">
     <table 
     	style="border:0px;width:100%;height:98%;border-collapse:collapse; border-spacing:0px;border-padding:0px;" 
     	class="login_bg"> <!-- width="100%" height="98%" border="0px" cellpadding="0" cellspacing="0"  -->
      <tr>
        <td width="98%" height="{if $isheader == 0}390px%{else}699px{/if}" align="left" style="padding:0px;">

            {$content}
			
            <div id="welcomearea" style="float:left;margin-left:28px;text-align:left;">
			<b> &Pi; <a href="{$url}" style="font-size:17px" >{$lang['navi_homepage']}</a> <span style="font-size:17px">&rarr;</span></b>
			{$lang['welcome_back']}！ {$lang['todayis']} <a href="#-万年历" target="_blank">
				<script type="text/javascript" src="./comm/show_today.js"></script></a>
            <br/> 

           <style type='text/css'>
		   .wrapper{
			      position: relative;
				     float: left;
					    left: 29px;
						   /*width: 850px;*/
						      margin-bottom: 20px;
							     /*background-color: #cccccc*/
		   }
		   .left1{
			      position: relative; word-break:break-all; word-wrap:break-word;
				     float: left; vertical-align:middle;padding:5px 5px 5px 5px;
					    left: 10px;
						   width: 150px;
						      height: 70px;
							     background-color: #cfcfcf
		   }
		   .left2{
			      position: relative; word-break:break-all; word-wrap:break-word;
				     float: left;vertical-align:middle;padding:5px 5px 5px 5px;
					    left: 30px;
						   width: 150px;
						      height: 70px;
							     background-color: #cfcfcf
		   }
		   .left3{
			      position: relative; word-break:break-all; word-wrap:break-word;
				     float: left;vertical-align:middle;padding:5px 5px 5px 5px;
					    left: 50px;
						   width: 150px;
						      height: 70px;
							     background-color: #cfcfcf
		   }
		   .left4{
			      position: relative; word-break:break-all; word-wrap:break-word;
				     float: left;vertical-align:middle;padding:5px 5px 5px 5px;
					    left: 70px;
						   width: 150px;
						      height: 70px;
							     background-color: #cfcfcf
		   }
		   .wrapperlog{
			      position: relative;
				     float: left;
					    left: 39px;
						   width: 670px;
						      margin-bottom: 20px;
							     background-color: #cccccc;
					padding-left:10px;
					padding-right:20px;
		   }
           td { word-break:break-word; }
		</style>
		<table style="width:700px; background:transparent; align:center; padding-top:10px;">

		{if is_array($navidir_list) && count($navidir_list)>0}
		<tr>
		<td>
		<b title="{$lang['navi_dir']}">ND. {$lang['navi_dir']}</b> | {$module_path} <br/>
		{$mi=0}
		{foreach $navidir_list as $k=>$v}
			{if $k==0}
			<!-- {$k} -->
			{else}
				{if $mi==0 || ($mi) % 4 == 0}
				<div class="wrapper">
				{/if}
					 {if $navidir_list[$k]['modulename'] != ''}
						{if $navidir_list[$k]['dynamicpara'] != ''}
					 	<a href="{$ido}&tbl={$navidir_list[$k]['modulename']}&db={$navidir_list[$k]['thedb']}&{$navidir_list[$k]['dynamicpara']}&levelcode={$navidir_list[$k]['levelcode']}">
						{else}
						<a href="{$ido}&tbl={$navidir_list[$k]['modulename']}&db={$navidir_list[$k]['thedb']}&levelcode={$navidir_list[$k]['levelcode']}">
						{/if}
					 {else}
					 	{if $navidir_list[$k]['dynamicpara'] != ''} <!-- extra modules -->
					 	<a href="{$rtvdir}/{$navidir_list[$k]['dynamicpara']}&sid={$sid}&db={$navidir_list[$k]['thedb']}&levelcode={$navidir_list[$k]['levelcode']}">
					 	{else}
					 	<a href="{$url}&navidir={$navidir_list[$k]['levelcode']}">
					 	{/if}
					 {/if}
					 <div class="left{(($k -1) % 4)+1}">
					 	<span style="size:14px; font-weight:bold;">{$mi+1}.{$navidir_list[$k]['linkname']}</span>
					 	<br/>(
						 {if $navidir_list[$k]['modulename'] != ''}
							{$navidir_list[$k]['modulename']}
						 {else}
							子目录/Subdir
						 {/if}
						 )</div></a>
				{if ($mi+1) % 4 == 0}
				</div>
				{/if}
				{$mi=$mi+1}
			{/if}
		{/foreach}	
		</td>
		</tr>
		{/if}
		
		<tr>
			<td colspan="10">
			<b title="{$lang['work_todo']}">WT. {$lang['work_todo']}</b><br/>
			<div id="tododiv" class="wrapperlog">
			<table style="border:0px; background:transparent;">
				<tr style="font-weight: bold;"><td>No.</td><td>{$lang['work_task']}</td><td>{$lang['state']}</td><td>{$lang['demand']}</td><td>{$lang['supply']}</td><td>{$lang['updatetime']}</td></tr>
				{foreach $todo_list as $k=>$v}
				<tr>
				<td>{$v['id']}.</td>
				{if $v['pid'] == '0'}
				<td><a href="{$ido}&tbl=fin_todotbl&pnskpid={$v['id']}&pnskid={$v['id']}&pnsm=0">{$v['taskname']}</a></td>
				{else}
				<td><a href="{$ido}&tbl=fin_todotbl&pnskpid={$v['pid']}&pnskid={$v['pid']}&pnsm=0">{$v['taskname']}</a></td>
				{/if}
				<td>{$todo_state[$v['state']]}</td>
				<td>{$user_list[$v['triggerbyparentid']]['email']}</td>
				<td>{$user_list[$v['touser']]['email']}</td>
				<td>{$v['updatetime']}</td>
				</tr>
				{/foreach}
				<tr><td style="white-space:nowrap;">
					<a href="{$ido}&tbl=fin_todotbl&pnobistate=1&tit={$lang['work_todo']}&pnsktouser={$userid}&pnsktriggerbyparentid={$userid}&pnobid=1&pnsm=0">{$lang['more']}...</a></td></tr>
			</table>
			</div>	
			</td>
		</tr>

		<tr>
		<td>
		<b title="{$lang['mostused_hint']}">MU. {$lang['mostused']}</b><br/>
		{$mi=0}
		{foreach $module_list_order as $k=>$v}
			{if $mi==0 || ($mi) % 4 == 0}
			<div class="wrapper">
			{/if}
				 <a href="{$ido}&tbl={$module_list_order[$k]}&db={$module_list_db[$module_list_order[$k]]}">
				 <div class="left{($k%4)+1}">
				 	<span style="size:14px; font-weight:bold;">{$mi+1}.
				 	{if $module_list_name[$module_list_order[$k]] != ''}
                            {$module_list_name[$module_list_order[$k]]}
                    {else}
                            {$module_list_order[$k]}
                    {/if}
				 	</span>
				 	<br/>({$module_list_order[$k]})
				 </div>
				 </a>
			{if ($mi+1) % 4 == 0}
			</div>
			{/if}
			{$mi=$mi+1}
		{/foreach}
		<!--
		<div class="wrapper">
			<div class="left1"></div>
			<div class="left2"></div>
			<div class="left3"></div>
			<div class="left4"></div>
		</div>
		-->
		</td>
		</tr><tr>
		<td>
		<b title="{$lang['desktop_shortcut_hint']}">DT. {$lang['desktop_shortcut']}</b><br/>
		{$mi=0}
		{foreach $module_list_byuser as $k=>$v}
			{if $mi==0 || ($mi) % 4 == 0}
			<div class="wrapper">
			{/if}
				 <a href="{$ido}&tbl={$v['tblname']}&db={$module_list_db[$v['tblname']]}"><div class="left{($k%4)+1}">
				 	<span style="size:14px; font-weight:bold;">{$mi+1}.{$v['objname']}</span><br/>({$v['tblname']})</div></a>
			{if ($mi+1) % 4 == 0}
			</div>
			{/if}
			{$mi=$mi+1}
		{/foreach}
		</td>
		</tr>

		<tr>
			<td colspan="10">
			<b title="{$lang['operatelog_hint']}">OL. {$lang['operatelog']}</b><br/>
			<div id="oplogdiv" class="wrapperlog">
			<table style="border:0px; background:transparent;">
				<tr style="font-weight: bold;"><td>{$lang['updatetime']}</td><td>{$lang['user']}/Id</td><td>{$lang['object']}/Id</td><td>{$lang['operation']}</td></tr>
				{foreach $log_list as $k=>$v}
				<tr>
				<td>{$v['inserttime']}</td>
				<td><a>{$user_list_ol[$v['userid']]}/{$v['userid']}</a></td>
				<td><a href="{$ido}&tbl={$v['parenttype']}">{$v['parenttype']}/{$v['parentid']}</a></td>
				<td>{$v['actionstr']}</td>
				</tr>
				{/foreach}
				<tr><td style="white-space:nowrap;"><a href="{$ido}&tbl=fin_operatelogtbl">{$lang['more']}...
					</a></td></tr>
			</table>
			</div>
			</td>
		</tr>

		<tr><td colspan="10">
		<script async type="text/javascript"> 
		function diffInYearsAndDays(startDate, endDate) {
			// Copy and normalise dates
			var d0 = new Date(startDate);
			d0.setHours(12,0,0,0);
			var d1 = new Date(endDate);
			d1.setHours(12,0,0,0);
			// Make d0 earlier date
			// Can remember a sign here to make -ve if swapped
			if (d0 > d1) {
				var t = d0;
				d0 = d1;
				d1 = t;
			}  
			// Initial estimate of years
			var dY = d1.getFullYear() - d0.getFullYear();
			// Modify start date
			d0.setYear(d0.getFullYear() + dY);
			// Adjust if required
			if (d0 > d1) {
				d0.setYear(d0.getFullYear() - 1);
				--dY;
			}
			// Get remaining difference in days
			var dD = (d1 - d0) / 8.64e7;
			// If sign required, deal with it here
			return [dY, dD];  
		}
		</script>
		<b><i>ii</i></b>. {$lang['sys_online']} <a href="{$url}"><script async type="text/javascript">
			diff=diffInYearsAndDays('{$start_date}',(new Date())); document.write(''+diff[0]+' year(s) '+diff[1]
			+' day(s)');</script></a> ,  <a href="{$ido}&tbl=info_usertbl"><b>{$user_count}</b></a> {$lang['user']} ，
			 <a href="{$ido}&tbl=info_objecttbl"><b> {$module_count}  </b></a> {$lang['module']}.  
			{$lang['updatetime']}: <a href='#-gmis' target='_blank'>{$system_lastmodify}</a> . 
			{$lang['online_user']} <a><b>{$logged_user_count}</b></a> . 
		</td></tr>

		<tr><td><b><i>HM</i></b>. <a href="{$front_page}" target="_blank">{$lang['homesite']}</a></td></tr>
		</table>
		<input type='hidden' id='indexurl' value='{$url}'/>
		<input type='hidden' id='watch_interval' value='{$watch_interval}'/>
		<input type='hidden' id='watch_interval_reload' value='{$watch_interval_reload}'/>
		<input type='hidden' id='rtvdir' value='{$rtvdir}'/>
		{literal}
		<script async type="text/javascript">
			var timeInterval = parseInt(document.getElementById('watch_interval').value); 
            var idxHomeWto=window.setTimeout(function(){
                    var watchRld = parseInt(document.getElementById('watch_interval_reload').value);
                    var timeInterval2 = parseInt(document.getElementById('watch_interval').value); 
                    var timePast = 0; var needGoout = false;
                    if(typeof userinfo.time2Quit != 'undefined'){
                        var time4Renew = userinfo.time4Renew;
                        timePast = timeInterval2 * 1000 * watchRld; 
                        if(timePast > time4Renew){
                            //- time to go out
                            needGoout = true;
                        }
                        else{
                            //- reload
						    }
                    }
                    else{
                        //- reload
                    }
                    if(!needGoout){
                        console.log('reload time:['+(new Date())+'] timePast:'+timePast+" time4Renew:"+userinfo.time4Renew);
                        window.location.href = document.getElementById('indexurl').value 
                            + '&watchRld=' + (watchRld + 1)+'&randi='+(Math.random());
                    }
                    else{
                        window.location.href = document.getElementById('rtvdir').value + '/?randi='+(Math.random()); 
                    }
				}, timeInterval * 1000);
		</script>
		{/literal}
		<br/>
            </div>
		<br/>
        </td>
      </tr>
     </table>

    </td>
  </tr>
 
</table>
{include file='footer.html'}
